import request from '@/utils/request'
import store from '@/store'

//添加作品
export function addCreation(creation: any) {
    return request({
        url: 'creations/add',
        method: 'post',
        data: creation,
        headers: { 'Authorization': store.getters.getToken }
    })
}


//获取作品列表
export function getCreationList(pageNum: number, pageSize: number, isFinish: number, keyword: string, type: string) {
    return request({
        url: 'creations/list',
        method: 'get',
        params: {
            pageNum: pageNum,
            pageSize: pageSize,
            isFinish: isFinish,
            keyword: keyword,
            type: type
        },
        headers: { 'Authorization': store.getters.getToken }
    })
}


//修改作品
export function updateCreation(creation: any) {
    return request({
        url: 'creations',
        method: 'put',
        data: creation,
        headers: { 'Authorization': store.getters.getToken }
    })
}


//点赞，取消点赞，收藏，取消收藏
export function operateCreation(id: number, operate: string, operateType: string, creation: any) {
    return request({
        url: 'creations/operate',
        method: 'put',
        params: {
            id: id,
            operate: operate,
            operateType: operateType
        },
        data: creation,
        headers: { 'Authorization': store.getters.getToken }
    })
}

